using System;
using System.Windows;
using System.Windows.Input;
namespace Microsoft.Phone.Gestures
{
	internal class ManipulationGestureHelper : GestureHelper
	{
		private class ManipulationBaseArgs : InputBaseArgs
		{
			public ManipulationBaseArgs(ManipulationStartedEventArgs args) : base(args.get_ManipulationContainer(), args.get_ManipulationOrigin())
			{
			}
		}
		private class ManipulationDeltaArgs : InputDeltaArgs
		{
			private ManipulationDeltaEventArgs _args;
			public override Point DeltaTranslation
			{
				get
				{
					return this._args.get_DeltaManipulation().get_Translation();
				}
			}
			public override Point CumulativeTranslation
			{
				get
				{
					return this._args.get_CumulativeManipulation().get_Translation();
				}
			}
			public override Point ExpansionVelocity
			{
				get
				{
					return this._args.get_Velocities().get_ExpansionVelocity();
				}
			}
			public override Point LinearVelocity
			{
				get
				{
					return this._args.get_Velocities().get_LinearVelocity();
				}
			}
			public ManipulationDeltaArgs(ManipulationDeltaEventArgs args) : base(args.get_ManipulationContainer(), args.get_ManipulationOrigin())
			{
				this._args = args;
			}
		}
		private class ManiulationCompletedArgs : InputCompletedArgs
		{
			private ManipulationCompletedEventArgs _args;
			public override Point TotalTranslation
			{
				get
				{
					return this._args.get_TotalManipulation().get_Translation();
				}
			}
			public override Point FinalLinearVelocity
			{
				get
				{
					if (this._args.get_FinalVelocities() != null)
					{
						return this._args.get_FinalVelocities().get_LinearVelocity();
					}
					return new Point(0.0, 0.0);
				}
			}
			public override bool IsInertial
			{
				get
				{
					return this._args.get_IsInertial();
				}
			}
			public ManiulationCompletedArgs(ManipulationCompletedEventArgs args) : base(args.get_ManipulationContainer(), args.get_ManipulationOrigin())
			{
				this._args = args;
			}
		}
		public ManipulationGestureHelper(UIElement target, bool shouldHandleAllDrags) : base(target, shouldHandleAllDrags)
		{
		}
		protected override void HookEvents()
		{
			base.Target.add_ManipulationStarted(new EventHandler<ManipulationStartedEventArgs>(this.Target_ManipulationStarted));
			base.Target.add_ManipulationDelta(new EventHandler<ManipulationDeltaEventArgs>(this.Target_ManipulationDelta));
			base.Target.add_ManipulationCompleted(new EventHandler<ManipulationCompletedEventArgs>(this.Target_ManipulationCompleted));
		}
		private void Target_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
		{
			base.NotifyDown(new ManipulationGestureHelper.ManipulationBaseArgs(e));
		}
		private void Target_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
		{
			base.NotifyMove(new ManipulationGestureHelper.ManipulationDeltaArgs(e));
		}
		private void Target_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
		{
			base.NotifyUp(new ManipulationGestureHelper.ManiulationCompletedArgs(e));
		}
	}
}
